<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      header {
        margin: auto;
        width: 500px;
        text-align: center;
      }
      #box {
        width: 200px;
        height: 200px;
        margin: auto;
        background-color: pink;
      }
    </style>
  </head>
  <body>
    <header>
      <p>属性名：<input type="text" id="inp1" value="background-color" /></p>
      <p>属性值：<input type="text" id="inp2" value="pink" /></p>
      <p>
        <button id="ok">确定</button>
        <button id="no">重置</button>
      </p>
    </header>
    <div id="box"></div>
  </body>
</html>
<script>
  var inp1 = document.getElementById("inp1");
  var inp2 = document.getElementById("inp2");
  var box = document.getElementById("box");
  ok.onclick = function () { 
    box.style.cssText = `${inp1.value}:${inp2.value}`; 
  };
  no.onclick=function(){
    box.style.cssText="width: 200px; height: 200px; margin: auto; background-color: pink;"
  }
</script>
